import { createApp } from 'vue'
import App from './App.vue'
import router from './router' // 确保路由已导入
import Header from '@/components/Layout/Header.vue'
import Sidebar from '@/components/Layout/Sidebar.vue'
import Footer from '@/components/Layout/Footer.vue'
import stores from "@/stores/index.js";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import {createPinia} from "pinia";
const Pinia = createPinia()
const app = createApp(App)
import {RefreshRight} from "@element-plus/icons-vue";
import {Sort} from "@element-plus/icons-vue";
import {Setting} from "@element-plus/icons-vue";
import {Plus} from "@element-plus/icons-vue";
// app.config.errorHandler = (err, vm, info) => {
//     console.error('[Global Error]', err)
//     if(err.message.includes('to is undefined')){
//         router.push('/error') // 跳转到错误页
//     }
// }
// 注册全局组件
app.component('Header', Header)
    .component('Sidebar', Sidebar)
    .component('Footer', Footer).component('RefreshRight',RefreshRight).component('Sort',Sort)
    .component('Setting',Setting).component('Plus',Plus)
// 挂载路由
app.use(router).use(ElementPlus).use(Pinia).use(stores)
app.mount('#app')